// 抽取基地址
const BASE_URL = 'https://www.uinav.com'

// 网络请求封装
export default function request({url,method,data,hasLoading=true}){
	return new Promise((resolve,reject) => {
		if(hasLoading){
			uni.showLoading({
				title:'加载中',
				mask:true
			})
			uni.showNavigationBarLoading()
		}
		uni.request({
			url:BASE_URL + url,
			method,
			success: (res) => {
				let {message,meta} =res.data
				if(meta.status === 200){
					resolve(message)
					if(hasLoading){
						uni.hideLoading()
						uni.hideNavigationBarLoading()
					}
				}else{
					reject()
				}
			},
		})
	})
}